package com.tmc.dao.impl.intair;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.tmc.bean.common.ContextInfo;
import com.tmc.bean.common.Pagination;
import com.tmc.dao.impl.BaseDaoImpl;
import com.tmc.entity.intair.IntairLog;


@Repository
public class IntairLogDaoImpl extends BaseDaoImpl<IntairLog>{
	public Pagination<IntairLog> findByCon(ContextInfo context, IntairLog cond, int pageIndex, int pageSize){
		Map<String, Object> params = new HashMap<String, Object>();
		StringBuilder sql = new StringBuilder();
		sql.append(" from  IntairLog  c  where c.enabledFlag = 'Y' ");
		if(cond.getOrderId() != null){
			sql.append(" and c.orderId = :orderId");
			params.put("orderId", cond.getOrderId());
		}
		sql.append(" order by c.lastUpdateDate asc ");
		return this.findPagination(sql.toString(), params, pageIndex, pageSize);
	}
	
	public List<IntairLog> findByOrderId(ContextInfo context, Long orderId){
		Map<String, Object> params = new HashMap<String, Object>();
		StringBuilder sql = new StringBuilder();
		sql.append(" from  IntairLog  c  where c.enabledFlag = 'Y' ");
		if(orderId != null){
			sql.append(" and c.orderId = :orderId");
			params.put("orderId", orderId);
		}
		sql.append(" order by c.lastUpdateDate asc ");
		return findList(sql.toString(), params);
	}
}
